package A_review.re2_11;

public class Class28 {

    public int strStr(String haystack, String needle) {

        int r=0,l=0;

        while (l<=haystack.length()-1&&r<=needle.length()-1){
            //TODO:2024/2/11   一个个比较
            while (l<=haystack.length()-1&&r<=needle.length()-1&&haystack.charAt(l)==needle.charAt(r)){
                r++;
                if (r==needle.length()){
                    return  l-r+1;
                }
                l++;
            }

            if (r==0){
                l++;
            }else if (r!=0){
                l=l-r+1;
                r=0;
            }



        }







        return  -1;
    }
}
